home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / system / skey40.zip / INPUTDEM.BAT < prev    next >
DOS Batch File  |  1991-12-23  |  3KB  |  96 lines

  1. :Batutil c(o) 1990, 1991 Barry Simon and Richard Wilson
  2. : Version 4.0
  3. echo off
  4. cls
  5. batutil {inc %0 code}
  6. goto end
  7. :echo1
  8. Welcome to the @1FBATUTIL@1E user input demo
  9.   This demonstration will show how BATUTIL can get
  10.   information from the user.
  11.  
  12. :echo2
  13.  
  14. The first way to get information is the GETKEY command.  We'll try
  15.     @1FBATUTIL {GE y n}
  16. and you'll need to reply with one key or the other.  Your choice will get
  17. echoed on the screen; it can get returned in the errorlevel or the
  18. environmental variable RC.  Now
  19.  
  20.    Please hit Y or N :
  21. :echo3
  22.  
  23.    GETKEY is case insensitive and flushes the keyboard buffer before looking
  24. for a response but you can change that or change whether there is a visible
  25. echo.  You can specify that a wrong choice get beeped or that a choice not on
  26. the list just returns a special errorlevel.  You can have BATUTIL exit with
  27. errorlevel 0 if there is no response in a specified time.  You can even
  28. have the time shown in a ticking clock on screen.  We'll show you the
  29. effect of
  30.    @1FBATUTIL {EC You have $$L   seconds left}{GE WA12 EL}
  31. after you hit any key.
  32.  
  33.  
  34. :echo4
  35.  
  36.  
  37. BATUTIL will also pop up a menu for you to choose from with the choice
  38. returned in the errorlevel.  The file menudemo.bat illustrates this or, if
  39. you are running this as a choice from the main demo program, just choose
  40. the MENU DEMONSTRATION from the main menu.
  41.  
  42. You can test for whether the CAPSLOCK key is pressed and branch on that; this
  43. is ideal for making a choice at the start of a long batch file and then
  44. leaving the room.
  45.    @1FBATUTIL {QL C -}
  46. will return errorlevel 1 if on and 0 if off and turn it off if on.
  47.  
  48. Please hit CAPSLOCK and then another key to continue.
  49.  
  50.  
  51. :echo5
  52. The errorlevel return was $r.
  53.  
  54. BATUTIL will also allow you to place strings in the environment.  First we'll
  55. ask you to input a string and then to choose a filename from BATUTIL's file
  56. picker.  Be sure to scroll to the bottom of the file list to see what can be
  57. done. Now hit a key to continue.
  58.  
  59.  
  60. :echo6
  61.  
  62.  
  63. The string you entered was
  64. $S                     $0
  65. and the filename was
  66. $S                     $1
  67. with a path of $2
  68.  
  69. You can also get numbers as input and do arithmetic on them.
  70. Please enter a pair of numbers:
  71. :echo7
  72.  
  73. Their sum is $V($1+$2) and their difference is $V($1-$2).
  74.  
  75. Thanks for using BATUTIL.  Hit a key to exit.
  76.  
  77. :code
  78. RC $
  79. CU - }{ CLS }{ RO 2 }{ CO 1
  80. FP %0 echo1 }{ GE WA2 }{ EC $_
  81. FP %0 echo2 }{ GE y n
  82. EC $_You picked choice $r$_
  83. FP %0 echo3 }{ GE EL
  84. EC You have $L   seconds left (or hit a key) }{ GE WA12 EL
  85. CL }{ FP %0 echo4 }{ GE EL }{ QL C -
  86. FE %0 echo5 }{ GE EL
  87. CL }{ EC $_$_Input a string$S }{ $0=$Q }{ RO -1 }{ EOL +
  88. FD $2 {$1=$F } FD FDIR     {FE %0 echo6
  89. REM  notice the use of FD $2 to store directory in an internal variable
  90. echoln }{ $1=$N
  91. $2=$N
  92. FE %0 echo7
  93. {RO T0}{CO T0}{GE WA5 EL}{EC $_}
  94. :end
  95.  
  96.